package reflect;

import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        Person p=new Person();
        System.out.println(p);
        Class cls=Person.class;
        Class cls1=Class.forName("reflect.Person");
       Object obj= cls1.newInstance();
        System.out.println(obj);

        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入一个完全限定名");
        String line=scanner.nextLine();
        Class cls2=Class.forName(line);
        Object obj1=cls2.newInstance();
        System.out.println(obj1);
    }
}
